var mongoose = require("mongoose");

// 创建规则
var rule = new mongoose.Schema({
    book_id: {
        type: mongoose.Schema.Types.ObjectId, 
        ref: 'msgs'
    },
    name: {
        type: String, 
        required: true,
    },
    author: {
        type: String,
        required: true,
    },
    num: {
        type: Number, 
        required: true,
    },
    desc: {
        type: String,
        required: true,
    },
    type: {
        type: Array,
        default: []
    }
}, {
    timestamps: true
});

// 把规则对应到一张具体的表，没有则创建
module.exports = db.model('books', rule);



